<span class="layui-breadcrumb">
    <a href="javascript:void(0)">当前位置:</a>
    <a href="javascript:void(0)">行方系统菜单 > </a>
     <a href="javascript:void(0)">系统管理 > </a>
    <a href="javascript:void(0)"><cite>菜单管理</cite> </a>
</span>
<@shiro.hasPermission name="caidantianjia">
<div class="layui-form-item layui-form-item-top">
	<button class="layui-btn-tan" id="addType">
		<i class="layui-icon">&#xe608;</i> 添加
	</button>
</div>
</@shiro.hasPermission>
<div class="levTable">
		<form class="layui-form" type="0"
			action="${basePath}system/menu/getMenulistPage" method="post"
			name="menuForm" id="menuForm">
			<table id="simple-table" class="table table-striped table-bordered table-hover" >
				<thead>
					<tr>
						<th>序号</th>
						<th>名称</th>
						<th>权限</th>
						<th>类型</th>
						<th>级别</th>
						<th style="width: 50px;">操作</th>
					</tr>
				</thead>
				<tbody>
					<#if "${menuList?has_content}"> <#list menuList as var >
					<tr>
						<td>${var_index?if_exists+1}</td>
						<td>${var.menuName }</td>
						<td>${var.permission }</td>
						<td>${var.menuType }</td>
						<td>${var.leveled }</td>
						<td>
                        <@shiro.hasPermission name="caidanshanchu">
                            <a  class="layui-icon" onclick="delMenu('${var.menuId }');" data-rel="tooltip" title="删除">
                                &#xe640;
                            </a>
                        </@shiro.hasPermission>
						</td>
					</tr>
					</#list> </#if>
				</tbody>
			</table>
		</form>

</div>
<#include "/common/page.html" />
<script type="text/javascript">
	var rooturl = "${basePath}/sysuser/menu/getMenulistPage";
    var _url = $("form:eq(0)").attr("action");
    $("#addType").click(function(){
        layer.open({
            type : 2,//此处以iframe举例
            title : '编辑',
            area : [ '750px', '600px' ],
            maxmin : true,
            content : '${basePath}sysuser/menu/toMenuEdit',
            btn : [ '保存', '关闭' ], //只是为了演示
            yes : function(index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.save();
            },
            no : function(index) {
                layer.close(index);
            },
            end : function() {
                reLoadPage(_url);
            }
        });
    });
	//检索
    function searchs() {
        $("#menuForm").submit();
    }
    //删除
    function delMenu(menuId){
        layer.confirm('确认要删除吗？', {
            btn: ['确定', '取消']
        }, function(index, layero){
            var url = "${basePath}sysuser/menu/deleteSysMenu?menuId="+menuId;
            $.ajax({url: url,
                type: "POST",
                success: function(data){
                    if (data.status == 'success') {
                        layer.alert(data.msg,function(index){
                            layer.close(index);
                            reLoadPage(_url);
                        });
                    }else{
                        layer.alert(data.msg);
                    }
                }
            })
        });
    }
</script>
